#manual branding - file won't load
transcend_cols = c("#1A4C81","#59C3B4","#EF464B","#ADE0EE")
transcend_cols2 = c("#BC2582","#FFA630","#FFDE42","#99C24D","#218380","#D3B7D7")
transcend_grays = c("#4D4D4F","#9D9FA2","#D1D3D4")
transcend_na = transcend_grays[2]
theme_transcend = theme_gdocs(base_size = 14, base_family = "Open Sans") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
theme_set(theme_transcend)

Cycle 2 - 2024 Only Tag Analysis

How long have schools been implementing each core practice?

time_tags <- full %>% 
  select(school_id, starts_with("time")) %>% 
  pivot_longer(cols = starts_with("time"),
               names_to = "practice",
               names_prefix = "time_",
               values_to = "frequency") %>% 
  # mutate(frequency = case_when(frequency == 0 ~ "Not a core practice",
  #                              frequency == 1 ~ "Less than a year",
  #                              frequency == 2 ~ "1-2 years",
  #                              frequency == 3 ~ "3-4 years",
  #                              frequency == 4 ~ "5+ years",
  #                              frequency == 5 ~ "Not sure")) %>% 
  group_by(practice, frequency) %>% 
  summarise(n = n())

5+ years

time_tags %>% 
  filter(frequency == "5+ years") %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head()
## # A tibble: 6 × 2
## # Groups:   practice [6]
##   practice                   n
##   <chr>                  <int>
## 1 pbl                       47
## 2 competency_education      37
## 3 accommodations            27
## 4 interdisciplinary         26
## 5 inclusion                 24
## 6 community_partnerships    23

3-4 years

time_tags %>% 
  filter(frequency == "3-4 years") %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head()
## # A tibble: 6 × 2
## # Groups:   practice [6]
##   practice                  n
##   <chr>                 <int>
## 1 pbl                      14
## 2 competency_education     12
## 3 mtss_academics           10
## 4 culturally_responsive     9
## 5 restorative               9
## 6 grading_mastery           7

1-2 years

time_tags %>% 
  filter(frequency == "1-2 years") %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head()
## # A tibble: 6 × 2
## # Groups:   practice [6]
##   practice                 n
##   <chr>                <int>
## 1 competency_education     8
## 2 restorative              7
## 3 career_prep              6
## 4 mtss_academics           6
## 5 sel_integrated           6
## 6 assessments_deeper       4

Less than a year

time_tags %>% 
  filter(frequency == "Less than a year") %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head(10)
## # A tibble: 10 × 2
## # Groups:   practice [10]
##    practice                  n
##    <chr>                 <int>
##  1 competency_framework      2
##  2 inclusion                 2
##  3 accommodations            1
##  4 adult_wellness            1
##  5 assessments_agency        1
##  6 assessments_deeper        1
##  7 career_prep               1
##  8 colead_family             1
##  9 competency_education      1
## 10 culturally_responsive     1

Not selected

time_tags %>% 
  filter(is.na(frequency)) %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head(10)
## # A tibble: 10 × 2
## # Groups:   practice [10]
##    practice                   n
##    <chr>                  <int>
##  1 enriched_virtual         189
##  2 heritage                 189
##  3 physical_well_being      189
##  4 assessments_bilingual    188
##  5 colead_industry          188
##  6 flipped_classroom        188
##  7 no_tracking              188
##  8 reallocation_resources   188
##  9 station_rotation         188
## 10 translanguaging          188

Recreating graphic from last year: top 10 core practices by time implemented:

top_10 <- time_tags %>% 
  filter(frequency == "5+ years") %>% 
  select(c(1, 3)) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  select(practice)

desired_order <- top_10$practice
tag_name <- dictionary %>% 
  select(variable_name, clean_labels) %>% 
  filter(str_starts(variable_name, "practice")) %>% 
  mutate(variable_name = str_remove(variable_name, "^practices_"))

labels <- setNames(tag_name$clean_labels, tag_name$variable_name)
top_10_time <- left_join(top_10, time_tags) %>% 
  mutate(pct = n/189) %>% 
  filter(!is.na(frequency))

top_10_time %>% 
  mutate(practice = fct_rev(factor(practice, levels = desired_order))) %>% 
  ggplot(aes(x = practice, y = pct, fill = frequency)) +
  geom_col(position = "stack") + 
  scale_x_discrete(labels = labels) +
  scale_y_continuous(labels = scales::percent_format(), expand = c(0, 0)) +
  coord_flip() +
  scale_fill_manual(values = c(transcend_cols2, transcend_na, transcend_cols[1])) +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt"),
    legend.position = "bottom"
  ) +
  labs(title = "Top 10 core practices by time implemented",
       x = "",
       y = "Percent of Canopy Schools",
       fill = "Time") +
  guides(fill = guide_legend(nrow = 1))

What are the top CORE tags selected when disaggregated? (By locale, level, type, leadership team, etc.)

Overall

time_vars <- tags %>% 
  select(starts_with("time")) %>% 
  pivot_longer(cols = everything(),
               names_to = "practice",
               values_to = "frequency",
               names_prefix = "time_") %>% 
  group_by(practice, frequency) %>% 
  summarise(count_tag = n())

# time_vars$frequency <- ifelse(is.na(time_vars$frequency), "Missing/Not Sure", time_vars$frequency)

time_vars <- time_vars %>% 
  pivot_wider(names_from = frequency,
              values_from = count_tag) %>% 
   mutate(`Not sure`= ifelse(is.na(`Not sure`), 0, `Not sure`),
          `Missing/Not Sure` = `NA` + `Not sure`) %>% 
  select(c(1, 6, 4, 5, 2, 8))
time_vars %>% datatable()
time_vars %>% 
  arrange(-`5+ years`) %>% 
  head() %>% 
  ggplot(aes(x = reorder(practice, `5+ years`), y = `5+ years`)) +
  geom_col(aes(fill = practice)) +
  geom_text(aes(label = `5+ years`), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Top Practices",
       title = "Practices Used Longest and Most Often") +
  scale_fill_manual(values = c(transcend_cols2, transcend_na, transcend_cols[1])) +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

Restrict to variables needed.

dis_agg_time <- full %>% 
  select(school_id, contains("locale_"), starts_with("grades_"), school_type, starts_with("time_")) %>%
  pivot_longer(cols = starts_with("time_"),
               names_to = "practice",
               names_prefix = "time_",
               values_to = "frequency")

School Type

school_type_tags <- dis_agg_time %>% 
  group_by(school_type, practice, frequency) %>% 
  summarise(n = n())
pds_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Public district school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Top Practices",
       title = "Public District Schools") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

pcs_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Public charter school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Public Charter Schools") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

ips_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Independent (private) school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Independent (Private) Schools") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
library(patchwork)

practices_descriptor_plot <- pds_viz + pcs_viz + ips_viz + plot_layout(ncol = 3) + 
  plot_annotation(title = "Practices Used Longest and Most Often - School Type",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_descriptor_plot

School Level

school_level_tags <- dis_agg_time %>% 
  select(school_id, practice, frequency, starts_with("grades_"), ) %>% 
  filter(frequency == "5+ years")
prek_viz <- school_level_tags %>% 
  filter(grades_pk == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Pre-Kindergarten") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

elem_viz <- school_level_tags %>% 
  filter(grades_elementary == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Elementary School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

middle_viz <- school_level_tags %>% 
  filter(grades_middle == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Middle School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

high_viz <- school_level_tags %>% 
  filter(grades_high == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "High School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_levels_plot <- prek_viz + elem_viz + middle_viz + high_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Practices Used Longest and Most Often - By the Levels Schools Offer",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_levels_plot

Locale

school_locale_tags <- dis_agg_time %>% 
  select(school_id, practice, frequency, contains("locale"), ) %>% 
  filter(frequency == "5+ years")
rural_viz <- school_locale_tags %>% 
  filter(locale_rural == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Rural") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

urban_viz <- school_locale_tags %>% 
  filter(locale_urban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Urban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

suburban_viz <- school_locale_tags %>% 
  filter(locale_suburban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Suburban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

multiple_locale_viz <- school_locale_tags %>% 
  filter(locale_multiple == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Multiple Locales") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_locale_plot <- rural_viz + urban_viz + suburban_viz + multiple_locale_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Practices Used Longest and Most Often - By School Locale",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_locale_plot

What are the top ALL tags selected when disaggregated? (By locale, level, type, leadership team, etc.)

dis_agg_all <- full %>% 
  select(school_id, contains("locale_"), starts_with("grades_"), school_type, starts_with("practices_")) %>%
  pivot_longer(cols = starts_with("practices_"),
               names_to = "practice",
               names_prefix = "practices_",
               values_to = "frequency")

Overall

dis_agg_all %>% 
  filter(frequency == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head() %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(aes(fill = practice)) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", size = 4, family = "sans") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Top Practices",
       title = "Practices Most Frequently Selected") +
  scale_fill_manual(values = c(transcend_cols2, transcend_na, transcend_cols[1])) +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

School Descriptor

school_type_tags <- dis_agg_all %>% 
  filter(frequency == 1) %>% 
  group_by(school_type, practice) %>% 
  summarise(n = n())
pds_viz <- school_type_tags %>% 
  filter(school_type == "Public district school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, max(school_type_tags$n) + 5)) +  
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Top Practices",
       title = "Public District") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

pcs_viz <- school_type_tags %>% 
  filter(school_type == "Public charter school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, max(school_type_tags$n) + 5)) +  
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Public Charter") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

ips_viz <- school_type_tags %>% 
  filter(school_type == "Independent (private) school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, max(school_type_tags$n) + 5)) +  
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Independent (Private)") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
library(patchwork)

practices_descriptor_plot <- pds_viz + pcs_viz + ips_viz + plot_layout(ncol = 3) + 
  plot_annotation(title = "Most Selected Practices - School Type",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_descriptor_plot

School Level

school_level_tags <- dis_agg_all %>% 
  select(school_id, practice, frequency, starts_with("grades_"), ) %>% 
  filter(frequency == 1)
prek_viz <- school_level_tags %>% 
  filter(grades_pk == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 132)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Pre-Kindergarten") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

elem_viz <- school_level_tags %>% 
  filter(grades_elementary == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 132)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Elementary School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

middle_viz <- school_level_tags %>% 
  filter(grades_middle == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 132)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Middle School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

high_viz <- school_level_tags %>% 
  filter(grades_high == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 132)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "High School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_levels_plot <- prek_viz + elem_viz + middle_viz + high_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Most Selected Practices - By the Levels Schools Offer",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_levels_plot

Locale

school_locale_tags <- dis_agg_all %>% 
  select(school_id, practice, frequency, contains("locale"), ) %>% 
  filter(frequency == 1)
rural_viz <- school_locale_tags %>% 
  filter(locale_rural == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 120)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Rural") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

urban_viz <- school_locale_tags %>% 
  filter(locale_urban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 120)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Urban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

suburban_viz <- school_locale_tags %>% 
  filter(locale_suburban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 120)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Suburban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

multiple_locale_viz <- school_locale_tags %>% 
  filter(locale_multiple == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 120)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Multiple Locales") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_locale_plot <- rural_viz + urban_viz + suburban_viz + multiple_locale_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Most Selected Practices - By School Locale",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_locale_plot

MODELING: Estimate model for each tag prevalence using (relatively) complete set of expanatory variables for general use in answering “How do tagging patterns differ across X?”

Rather than individual tag, I’m going to run this on the recommended clusters for this year.

Following Janette’s cluster_trends doc, I am implementing a binomial logistic regression here.

cluster <- import(here("data/longitudinal", "tag_clusters_longitudinal.csv")) %>% 
  janitor::clean_names()

deeper_cluster <- cluster %>% 
  filter(proposed_cluster_for_preliminary_24_analysis == "Deeper learning") %>% 
  pull(tag)

ed_justice_cluster <- cluster %>% 
  filter(proposed_cluster_for_preliminary_24_analysis == "Ed justice") %>% 
  pull(tag)

individualized_cluster <- cluster %>% 
  filter(proposed_cluster_for_preliminary_24_analysis == "Individualized") %>% 
  pull(tag)

postsecondary_cluster <- cluster %>% 
  filter(proposed_cluster_for_preliminary_24_analysis == "Postsecondary") %>% 
  pull(tag)

no_cluster <- cluster %>%
  filter(proposed_cluster_for_preliminary_24_analysis == "None" |
           proposed_cluster_for_preliminary_24_analysis == "None?") %>%
  pull(tag)
tags_long <- tags %>% 
  select(school_id, starts_with("practice")) %>% 
  pivot_longer(cols = starts_with("practice"),
               names_to = "var",
               names_prefix = "practices_",
               values_to = "usage") %>% 
  mutate(var = recode(var, !!!labels)) %>% 
  mutate(cluster = case_when(
    var %in% deeper_cluster ~ "deeper",
    var %in% ed_justice_cluster ~ "ed_justice",
    var %in% individualized_cluster ~ "individualized",
    var %in% postsecondary_cluster ~ "postsecondary",
    var %in% no_cluster ~ "misc"
  ))

mod_dat <- tags_long %>% 
  group_by(cluster, school_id) %>% 
  summarise(total = n_distinct(var),
            n = sum(usage),
            pct = n/total) %>% 
  select(school_id, cluster, n, pct) %>% 
  ungroup() %>% 
  pivot_wider(names_from = cluster,
              values_from = c(n, pct))

#read in characteristic vars for modeling and merge
vars <- full %>% 
  select(school_id, school_type, school_locale, leadership_diversity, school_enrollment, pct_bipoc, pct_ell, pct_frpl, pct_swd, grades_pk, grades_elementary, grades_middle, grades_high) %>% 
  mutate(c_enrollment = scale(school_enrollment, center = TRUE, scale = TRUE)[,1],
         c_bipoc = scale(pct_bipoc, center = TRUE, scale = TRUE)[,1],
         c_ell = scale(pct_ell, center = TRUE, scale = TRUE)[,1],
         c_frpl = scale(pct_frpl, center = TRUE, scale = TRUE)[,1],
         c_swd = scale(pct_swd, center = TRUE, scale = TRUE)[,1]) %>% 
  select(-c(school_enrollment, starts_with("pct")))

#merge
mod_dat <- mod_dat %>% 
  left_join(vars, by = c("school_id"))

# set vars of interest
dv <- mod_dat %>% select(starts_with("n_")) %>% colnames()

preds <- mod_dat %>% select(-school_id, -starts_with("pct_"), -starts_with("n_")) %>% colnames()

Begin model setup

log_dat <- mod_dat %>% 
  mutate(tot_deeper = 12, # total = 12
         tot_ed_justice = 19, # total = 19
         tot_individualized = 9, # total = 9
         tot_misc = 24, # total = 24
         tot_postsecondary = 9, # total = 9
         max_deeper = 12,
         max_ed_justice = 19,
         max_individualized = 9,
         max_misc = 24,
         max_postsecondary = 9) %>% 
  pivot_longer(cols = c(starts_with("n_"), starts_with("pct_"), starts_with("tot_"), starts_with("max_")),
               names_to = c(".value", "cluster"),
               names_pattern = "^([^_]+)_(.*)$") %>% 
  rowwise() %>% 
  mutate(success = n,
         failure = max - n,
         school_type = factor(school_type, levels = c("Public district school", "Public charter school", "Independent (private) school")),
         school_locale = factor(school_locale, levels = c("Urban", "Suburban", "Rural", "Multiple")))

Deeper Learning

#manual run because loops aren't working - deeper learning
deep <- log_dat %>% 
  filter(cluster == "deeper") %>% 
  filter(!if_any(all_of(preds), is.na))

deep_mod <- glm(cbind(success, failure) ~ school_type + school_locale + grades_pk + grades_elementary + grades_high + c_enrollment + c_bipoc + c_ell + c_swd,
                family = binomial,
                data = deep)
# plot
tidy(deep_mod, effects = "ran_pars", conf.int = TRUE) %>%
  filter(term != "(Intercept)") %>%
  mutate(estimate = exp(estimate)) %>% 
  ggplot(., aes(y = fct_reorder(term, estimate), x = estimate)) +
  geom_linerange(aes(xmin = estimate - std.error,
                     xmax = estimate + std.error),
                 color = "blue") +
  geom_point() +
  geom_vline(xintercept = 1) +
  theme_transcend +
  theme(panel.grid.major.y = element_blank()) +
  labs(
    x = "Likelihood",
    y = "",
    title = "School characteristics describing \ndeeper learning")

Ed Justice

ed_justice <- log_dat %>% 
  filter(cluster == "ed_justice") %>% 
  filter(!if_any(all_of(preds), is.na))

ed_justice_mod <- glm(cbind(success, failure) ~  school_type + school_locale + grades_pk + grades_elementary + grades_high + c_enrollment + c_bipoc + c_ell + c_swd + offset(log(max)),
                family = binomial,
                data = ed_justice)
# plot
tidy(ed_justice_mod, effects = "ran_pars", conf.int = TRUE) %>%
  filter(term != "(Intercept)") %>%
  mutate(estimate = exp(estimate)) %>% 
  ggplot(., aes(y = fct_reorder(term, estimate), x = estimate)) +
  geom_linerange(aes(xmin = estimate - std.error,
                     xmax = estimate + std.error),
                 color = "blue") +
  geom_point() +
  geom_vline(xintercept = 1) +
  theme_transcend +
  theme(panel.grid.major.y = element_blank()) +
  labs(
    x = "Likelihood",
    y = "",
    title = "School characteristics describing \neducational justice")

Individualized Learning

individualized <- log_dat %>% 
  filter(cluster == "individualized") %>% 
  filter(!if_any(all_of(preds), is.na))

individualized_mod <- glm(cbind(success, failure) ~  school_type + school_locale + grades_pk + grades_elementary + grades_high + c_enrollment + c_bipoc + c_ell + c_swd,
                family = binomial,
                data = individualized)
# plot
tidy(individualized_mod, effects = "ran_pars", conf.int = TRUE) %>%
  filter(term != "(Intercept)") %>%
  mutate(estimate = exp(estimate)) %>% 
  ggplot(., aes(y = fct_reorder(term, estimate), x = estimate)) +
  geom_linerange(aes(xmin = estimate - std.error,
                       xmax = estimate + std.error),
                   color = "blue") +
  geom_point() +
  theme_transcend +
  geom_vline(xintercept = 1) +
  theme(panel.grid.major.y = element_blank()) +
  labs(x = "Likelihood",
       y = "",
       title = "School characteristics describing \nindividualized learning")

Postsecondary Pathways

postsecondary <- log_dat %>% 
  filter(cluster == "postsecondary") %>% 
  filter(!if_any(all_of(preds), is.na))

postsecondary_mod <- glm(cbind(success, failure) ~ school_type + school_locale + grades_pk + grades_elementary + grades_high + c_enrollment + c_bipoc + c_ell + c_swd + offset(log(max)),
                family = binomial,
                data = postsecondary)
# plot
tidy(postsecondary_mod, effects = "ran_pars", conf.int = TRUE) %>%
  filter(term != "(Intercept)") %>%
  mutate(estimate = exp(estimate)) %>% 
  ggplot(., aes(y = fct_reorder(term, estimate), x = estimate)) +
  geom_linerange(aes(xmin = estimate - std.error,
                       xmax = estimate + std.error),
                   color = "blue") +
  geom_point() +
  geom_vline(xintercept = 1) +
  theme_transcend +
  theme(panel.grid.major.y = element_blank()) +
  labs(x = "Likelihood",
       y = "",
       title = "School characteristics describing \npostsecondary pathways")

Miscellaneous

misc <- log_dat %>% 
  filter(cluster == "misc") %>% 
  filter(!if_any(all_of(preds), is.na))

misc_mod <- glm(cbind(success, failure) ~ school_type + school_locale + grades_pk + grades_elementary + grades_high + c_enrollment + c_bipoc + c_ell + c_swd + offset(log(max)),
                family = binomial,
                data = misc)
# plot
tidy(misc_mod, effects = "ran_pars", conf.int = TRUE) %>%
  filter(term != "(Intercept)") %>%
  mutate(estimate = exp(estimate)) %>% 
  ggplot(., aes(y = fct_reorder(term, estimate), x = estimate)) +
  geom_linerange(aes(xmin = estimate - std.error,
                     xmax = estimate + std.error),
                     color = "blue") +
  geom_point() +
  geom_vline(xintercept = 1) +
  theme_transcend +
  theme(panel.grid.major.y = element_blank()) +
  labs(x = "Likelihood",
       y = "",
       title = "School characteristics describing \ntags without a cluster")

What are the top core and pilot tags being implemented?

Core

core_tags <- full %>% 
  select(school_id, starts_with("core")) %>% 
  pivot_longer(cols = starts_with("core"),
               names_to = "practice",
               names_prefix = "core_",
               values_to = "frequency") %>% 
  filter(frequency == 1) %>% 
  select(-frequency)
core_tags %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols2[2]) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", size = 4, family = "sans") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Practices",
       y = "Number of Schools",
       title = "Top Core Practices") +
  scale_fill_manual(values = c(transcend_cols2, transcend_na, transcend_cols[1])) +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

What are the newest core tags being implemented?

pilot_tags <- full %>% 
  select(school_id, starts_with("pilot")) %>% 
  pivot_longer(cols = starts_with("pilot"),
               names_to = "practice",
               names_prefix = "pilot_",
               values_to = "frequency") %>% 
  filter(frequency == 1) %>% 
  select(-frequency)
pilot_tags %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols2[3]) +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", size = 4, family = "sans") +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Practices",
       y = "Number of Schools",
       title = "Top Pilot Tags") +
  scale_fill_manual(values = c(transcend_cols2, transcend_na, transcend_cols[1])) +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

What are the top core tags schools have been implementing for 5 or more years?

Already ran above.

What are the newest core tags being implemented?

Restrict to variables needed.

dis_agg_time <- full %>% 
  select(school_id, contains("locale_"), starts_with("grades_"), school_type, starts_with("time_")) %>%
  pivot_longer(cols = starts_with("time_"),
               names_to = "practice",
               names_prefix = "time_",
               values_to = "frequency")

Overall

dis_agg_time %>% 
  group_by(practice, frequency) %>% 
  summarise(n = n()) %>% 
  filter(frequency == "1-2 years") %>% 
  arrange(desc(n)) %>% 
  head(10)
## # A tibble: 10 × 3
## # Groups:   practice [10]
##    practice              frequency     n
##    <chr>                 <chr>     <int>
##  1 competency_education  1-2 years     8
##  2 restorative           1-2 years     7
##  3 career_prep           1-2 years     6
##  4 mtss_academics        1-2 years     6
##  5 sel_integrated        1-2 years     6
##  6 assessments_deeper    1-2 years     4
##  7 culturally_responsive 1-2 years     4
##  8 design_marginalized   1-2 years     4
##  9 hiring_equity         1-2 years     4
## 10 inclusion             1-2 years     4

School Type

school_type_tags <- dis_agg_time %>% 
  group_by(school_type, practice, frequency) %>% 
  summarise(n = n())
pds_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Public district school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = "Top Practices",
       title = "Public District Schools") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

pcs_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Public charter school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Public Charter Schools") +
  theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

ips_viz <- school_type_tags %>% 
  filter(frequency == "5+ years",
         school_type == "Independent (private) school") %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 25)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Independent (Private) Schools") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
library(patchwork)

practices_descriptor_plot <- pds_viz + pcs_viz + ips_viz + plot_layout(ncol = 3) + 
  plot_annotation(title = "Practices Used Longest and Most Often - School Type",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_descriptor_plot

School Level

school_level_tags <- dis_agg_time %>% 
  select(school_id, practice, frequency, starts_with("grades_"), ) %>% 
  filter(frequency == "5+ years")
prek_viz <- school_level_tags %>% 
  filter(grades_pk == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Pre-Kindergarten") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

elem_viz <- school_level_tags %>% 
  filter(grades_elementary == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Elementary School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

middle_viz <- school_level_tags %>% 
  filter(grades_middle == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Middle School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

high_viz <- school_level_tags %>% 
  filter(grades_high == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "High School") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_levels_plot <- prek_viz + elem_viz + middle_viz + high_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Practices Used Longest and Most Often - By the Levels Schools Offer",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_levels_plot

Locale

school_locale_tags <- dis_agg_time %>% 
  select(school_id, practice, frequency, contains("locale"), ) %>% 
  filter(frequency == "5+ years")
rural_viz <- school_locale_tags %>% 
  filter(locale_rural == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[1], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Rural") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

urban_viz <- school_locale_tags %>% 
  filter(locale_urban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[2], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Urban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

suburban_viz <- school_locale_tags %>% 
  filter(locale_suburban == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[3], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Suburban") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )

multiple_locale_viz <- school_locale_tags %>% 
  filter(locale_multiple == 1) %>% 
  group_by(practice) %>% 
  summarise(n = n()) %>% 
  arrange(desc(n)) %>% 
  head(10) %>% 
  ggplot(aes(x = reorder(practice, n), y = n)) +
  geom_col(fill = transcend_cols[4], position = "dodge") +
  geom_text(aes(label = n), nudge_y = 0.5, hjust = 0, color = transcend_na, fontface = "bold", family = "sans") +
  scale_y_continuous(limits = c(0, 40)) +
  coord_flip() +
  theme_bw() +
  theme(legend.position = "none") +
  labs(x = " ",
       title = "Multiple Locales") +
    theme(
    plot.title = element_text(family = "Bebas Neue", color = "black"),
    plot.background = element_blank(),
    axis.text = element_text(colour = "black"),
    axis.title = element_text(colour = "black"),
    panel.border = element_rect(colour = "#4D4D4F"),
    strip.text = element_text(size = rel(0.8)),
    plot.margin = margin(10, 24, 10, 10, "pt")
  )
practices_locale_plot <- rural_viz + urban_viz + suburban_viz + multiple_locale_viz + plot_layout(ncol = 2) + 
  plot_annotation(title = "Practices Used Longest and Most Often - By School Locale",
                  theme = theme(plot.title = element_text(hjust = 0.5)))
practices_locale_plot